package com.excellence.controller;

import com.excellence.datamodel.Result;
import com.excellence.pojo.Warning;
import com.excellence.service.WarningService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author 沈秉璋
 * @ClassName WarningController
 * @Description TODO
 * @date 2024/4/8 11:41
 * @Version 1.0
 */

//@Controller
//@ResponseBody
@Slf4j
@RestController
@RequestMapping("/api/warning")
public class WarningController {

    @Autowired
    private WarningService warningService;

    @PutMapping("/deleteByKey")
    Result deleteByKey(Long id) {
        int res = warningService.deleteByKey(id);
        return Result.success(res);
    }

    @DeleteMapping("/deleteByPrimaryKey")
    Result deleteByPrimaryKey(Long id) {
        int res = warningService.deleteByPrimaryKey(id);
        return Result.success(res);
        //没测
    }

    @PostMapping("/insert")
    Result insert(Warning record) {
        log.info("{}", record);
        int res = warningService.insert(record);
        return Result.success(res);
    }

    @PostMapping("/insertSelective")
    Result insertSelective(Warning record) {
        int res = warningService.insertSelective(record);
        return Result.success(res);
        //没测
    }

    @GetMapping("/selectByPrimaryKey")
    Result selectByPrimaryKey(Long id) {
        Warning res = warningService.selectByPrimaryKey(id);
        return Result.success(res);
    }

    @GetMapping("/selectAll")
    Result selectAll() {
        List<Warning> res = warningService.selectAll();
        return Result.success(res);
    }

    @PutMapping("/updateByPrimaryKeySelective")
    Result updateByPrimaryKeySelective(Warning record) {
        int res = warningService.updateByPrimaryKeySelective(record);
        return Result.success(res);
    }

    @PutMapping("/updateByPrimaryKey")
    Result updateByPrimaryKey(Warning record) {
        int res = warningService.updateByPrimaryKey(record);
        return Result.success(res);
        //没测
    }
}
